home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 335 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: clamage@Eng.sun.com (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: friend class declaration and nested classe
  5. Date: 7 Feb 1996 22:00:25 GMT
  6. Organization: Sun Microsystems Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4fb77t$qsq@engnews1.Eng.Sun.COM>
  9. References: <4fa71q$1rp@fsuj01.rz.uni-jena.de>
  10. Reply-To: clamage@Eng.sun.com
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: taumet.eng.sun.com
  14. Content-Length: 988
  15. X-Lines: 48
  16. Originator: clamage@taumet
  17.  
  18. In article 1rp@fsuj01.rz.uni-jena.de,  mkt@isun04.inf.uni-jena.de (Tilo Koerbs) writes:
  19.  
  20. >    class X;
  21.  
  22. >    class Y {
  23. >        class X {};
  24. >        friend class ::X;  // error!!!
  25. >    };
  26.  
  27. No, that example is OK.
  28.  
  29. >I watched the ARM and found out:
  30. >    Section 11.4: "... All the functions of a class X can be
  31. >        made friends of a class Y by a single declaration
  32. >        using an 'elaborated-type-specifier' ('9.1):
  33.  
  34. >            class Y {
  35. >                friend class X;
  36. >                // ...
  37. >            };"
  38.  
  39. >    'elaborated-type-specifier':
  40. >        'class-key' 'class-name'
  41. >        'class-key' 'identifier'
  42. >        enum 'enum-name'
  43.  
  44. >    'class-key':
  45. >        class
  46. >        struct
  47. >        union
  48.  
  49. >    'class-name':
  50. >        'identifier'
  51.  
  52. The grammar in the ARM is not quite complete or correct. The draft standard says
  53.  
  54.     elaborated-type-specifier:
  55.         class-key  ::[opt]  nested-name-specifier[opt] identifier
  56.         enum  ::[opt]  nested-name-specifier[opt] identifier
  57.  
  58. So things like
  59.     friend class ::X;
  60.     friend class A::B::X;
  61. are allowed by the syntax.
  62.  
  63. ---
  64. Steve Clamage, stephen.clamage@eng.sun.com
  65.  
  66.  
  67. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  68.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  69.   summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  70. ]
  71.